import {defineStore} from 'pinia'

enum cacheName {
    accessToken = "accessToken",
    username = "username"
}

export const useCounterStore = defineStore('counter', () => {

    const getToken = (): string | null => {
        return localStorage.getItem(cacheName.accessToken);
    }

    const setToken = (accessToken: string): void => {
        localStorage.setItem(cacheName.accessToken, accessToken)
    }

    const removeToken = (): void => {
        localStorage.removeItem(cacheName.accessToken)
    }

    const getUsername = (): string | null => {
        return localStorage.getItem(cacheName.username);
    }

    const setUsername = (username: string): void => {
        localStorage.setItem(cacheName.username, username)
    }

    const removeUsername = (): void => {
        localStorage.removeItem(cacheName.username)
    }

    return {getToken, setToken, removeToken, getUsername, setUsername, removeUsername}
})
